package com.yt.app.api.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Description
 * <p>
 * </p>
 * DATE 2017/11/1.
 *
 * @author liujunshi.
 */
public class PatternUtil {
    public static Pattern EMAIL_PATTERN = Pattern.compile("\\w+(\\.\\w)*@\\w+(\\.\\w{2,3}){1,3}");

    public static Pattern USER_NAME_PATTERN = Pattern.compile("^[a-zA-Z\\u4E00-\\u9FA5]{1,20}$");

    public static Pattern MOBILE_PATTERN = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");

    public static Pattern MOBILE_MASK_PATTERN = Pattern.compile("(\\w{3})(\\w+)(\\w{4})");

    public static String getMaskMobile(String mobile){
        Matcher m = PatternUtil.MOBILE_MASK_PATTERN.matcher(mobile);
        if(m.matches()){
            return m.replaceAll("$1****$3");
        }
        return null;

    }
}